const mysql2 = require("mysql2");
const pool = mysql2.createPool({
  host: "127.0.0.1",
  user: "root",
  password: "admin123",
  database: "db",
});

// 封装查询函数
module.exports = function sqlQuery(sql, params) {
  return new Promise((resolve, reject) => {
    pool.query(sql, params, (err, results) => {
      if (err) {
        reject(err);
      } else {
        resolve(results);
      }
    });
  });
};
